/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.myapp.struts.actionform;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

/**
 *
 * @author pavan
 */
public class EditMaterialTypeFormBean extends org.apache.struts.action.ActionForm {

    private String typeEdit, newType;

    public String getNewType() {
        return newType;
    }

    public void setNewType(String newType) {
        this.newType = newType;
    }

    public String getTypeEdit() {
        return typeEdit;
    }

    public void setTypeEdit(String typeEdit) {
        this.typeEdit = typeEdit;
    }

    /**
     *
     */
    public EditMaterialTypeFormBean() {
        super();
        // TODO Auto-generated constructor stub
    }

    /**
     * This is the action called from the Struts framework.
     * @param mapping The ActionMapping used to select this instance.
     * @param request The HTTP Request we are processing.
     * @return
     */
    @Override
    public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
        ActionErrors errors = new ActionErrors();
        if (getNewType() == null || getNewType().length() < 1) {
            errors.add("newType", new ActionMessage("error.newType.required"));
            // TODO: add 'error.name.required' key to your resources
        }

        if (getTypeEdit().trim().equals("Select") || getTypeEdit().length() < 1) {
            System.out.println(getTypeEdit().length() + "----------" + getTypeEdit().trim().equals("Select"));
            errors.add("typeEdit", new ActionMessage("error.typeEdit.required"));
            // TODO: add 'error.name.required' key to your resources
        }

        return errors;
    }
}
